import { lazy } from "react";
import { MainLayout } from "../components";
import { RouteRawState } from "../types";
import { Navigate } from "react-router-dom";
import {
  HomeOutlined,
  SettingOutlined,
  UnorderedListOutlined,
  AppstoreAddOutlined,
  MenuOutlined,
} from "@ant-design/icons";
const Home = lazy(() => import("../views/home"));
const Signin = lazy(() => import("../views/signin"));
const ListManage = lazy(() => import("../views/listManage"));
const ListAdd = lazy(() => import("../views/listAdd"));
const Detail = lazy(() => import("../views/detail"));
const Set = lazy(() => import("../views/set"));
export const routes: RouteRawState[] = [
  {
    path: "/home",
    element: (
      <MainLayout>
        <Home></Home>
      </MainLayout>
    ),
    meta: {
      title: "首页",
      icon: <HomeOutlined />,
    },
  },
  {
    path: "/signin",
    element: <Signin></Signin>,
    hidden: true,
    meta: {
      title: "登录",
    },
  },
  {
    path: "/",
    element: <Navigate to="/home"></Navigate>,
    hidden: true,
    meta: {
      title: "重定向",
    },
  },
  {
    path: "/list",
    meta: {
      title: "列表操作",
      icon: <MenuOutlined />,
    },
    children: [
      {
        path: "/list/manage",
        element: (
          <MainLayout>
            <ListManage></ListManage>
          </MainLayout>
        ),
        meta: {
          title: "列表管理",
          icon: <UnorderedListOutlined />,
          role: ["test", "user", "teacher"],
        },
      },
      {
        path: "/list/add",
        element: (
          <MainLayout>
            <ListAdd></ListAdd>
          </MainLayout>
        ),
        meta: {
          title: "列表添加",
          icon: <AppstoreAddOutlined />,
          role: [],
        },
      },
      {
        path: "/list/user",
        children: [
          {
            path: "/list/user/manage",
            element: (
              <MainLayout>
                <div>用户列表管理</div>
              </MainLayout>
            ),
            meta: {
              title: "用户列表管理",
            },
          },
          {
            path: "/list/user/query",
            element: (
              <MainLayout>
                <div>用户列表查询</div>
              </MainLayout>
            ),
            meta: {
              title: "用户列表查询",
            },
          },
        ],
        meta: {
          title: "用户列表",
        },
      },
    ],
  },
  {
    path: "/detail/:id",
    element: <Detail></Detail>,
    hidden: true,
    meta: {
      title: "详情页",
    },
  },
  {
    path: "/set",
    meta: {
      title: "设置",
      icon: <SettingOutlined />,
      role: ["admin"],
    },
    children: [
      {
        path: "/set/user",
        element: (
          <MainLayout>
            <Set></Set>
          </MainLayout>
        ),
        meta: {
          title: "用户设置",
          icon: <SettingOutlined />,
        },
      },
    ],
  },
  {
    path: "*",
    element: <div>404 Not Found</div>,
    hidden: true,
    meta: {
      title: "404 页面找不到",
    },
  },
];
